using System;
using System.ComponentModel.Design;

namespace Microsoft.WowAddonStudio.FrameXml.Components.Behaviors
{
    public abstract class DesignerBehavior : IDisposable
    {
        private readonly IDesignerHost designerHost;

        protected DesignerBehavior(IDesignerHost designerHost)
        {
            if (designerHost == null)
                throw new ArgumentNullException("designerHost");

            this.designerHost = designerHost;
        }

        public IDesignerHost DesignerHost
        {
            get { return designerHost; }
        }

        public abstract void Initialize();

        protected TService GetService<TService>()
        {
            return (TService)designerHost.GetService(typeof(TService));
        }

        public virtual void Dispose()
        {
        }
    }
}